package com.twu.biblioteca.DAO;

import com.twu.biblioteca.model.Book;
import com.twu.biblioteca.model.Movie;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by akutschm on 06/05/2014.
 */
public class MovieDAO {

    private final List<Movie> movies;

    public MovieDAO() {
        movies = new ArrayList<Movie>();
        movies.add(new Movie(1, "Fear and Loathing in Las Vegas", 1998, "Terry Gillam", 8, false));
        movies.add(new Movie(2, "Life of Brian", 1979, "Terry Jones", 8, false));
        movies.add(new Movie(3, "Mad Max", 1979, "George Miller", 7, true));
    }

    public List<Movie> findAvailableMovies() {
        List<Movie> availableMovies = new ArrayList();
        for (Movie movie: movies) {
            if (!movie.isReserved()) {
                availableMovies.add(movie);
            }
        }
        return availableMovies;
    }

    public Movie find(int id) {
        for (Movie movie: movies) {
            if (movie.getId() == id) {
                return movie;
            }
        }
        return null;
    }


}
